package org.wzh.sort.util;

public class DataUtils {
	
	public static final Integer BEFORE = 1;
	public static final Integer AFTER = 0;
	public static final Integer DEBUG = -1;

	private DataUtils() {
	};
	
	public static <T> void show(T[] a) throws Exception {
		show(a, -1, DataUtils.DEBUG);
	};

	public static <T> void show(T[] a, int formatter, int flag) throws Exception {
		switch (flag) {
		case 1:
			System.out.println("Before sort ..");
			break;
		case 0:
			System.out.println("After sort ..");
			break;
		case -1:
			break;
		default:
			System.out.println("Error param !!");
			throw new Exception("Error param!!");
		}
		
		if (formatter < 1) {
			for (int i = 0; i < a.length; i++) {
				System.out.print(a[i] + "\t");
			}
		} else {
			int j = 1;
			for (int i = 0; i < a.length; i++) {
				System.out.print(a[i] + "\t");
				if (++j > formatter) {
					System.out.println();
					j = 1;
				}
			}
		}
		System.out.println();
	}

}
